package com.tsll.controller;

import com.tsll.annotation.MyLog;
import com.tsll.entity.Role;
import com.tsll.entity.Staffsal;
import com.tsll.service.RoleService;
import com.tsll.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    @MyLog(businessName = "查询角色")
    @GetMapping("/list/{current}/{pageSize}")
    public Result list(@PathVariable Integer current, @PathVariable Integer pageSize){
        return roleService.findAll(current, pageSize);
    }
    @MyLog(businessName = "修改角色状态")
    @GetMapping("/updateStatus")
    public Result updateStatus(Integer id,Integer status){
        return roleService.updateStatus(id,status);
    }
//    删除
    @MyLog(businessName = "删除角色")
    @RequestMapping("/delete/{id}")
    public Result deleteAll(@PathVariable Integer id){
        Result result = roleService.deleteAll(id);
        return result;
    }
    //根据部门id查找部门职位
    @MyLog(businessName = "查找部门职位")
    @GetMapping("/selectByDeptid")
    public Result selectByDeptid(Integer deptid){
        return roleService.selectByDept(deptid);
    }
    @MyLog(businessName = "查询所有角色")
    @GetMapping("/selectRoles")
    public Result selectAll(){
        return roleService.selectAll();
    }
    @MyLog(businessName = "修改角色信息")
    @RequestMapping("/update")
    public Result update( @RequestBody Role role){
        Result update = roleService.update(role);
        return update;
    }
    /**
     * 请求映射路径为/insert，用于插入一个新的Role信息
     */
    @MyLog(businessName = "添加角色")
    @RequestMapping("/insert")
    public Result insert(@RequestBody Role role){
        Result i = roleService.insertAll(role);
        return i;
    }

}
